package cn.wolfcode.wolf2w.job.task;

import cn.wolfcode.wolf2w.business.api.RemoteStrategyConditionService;
import cn.wolfcode.wolf2w.business.api.RemoteStrategyRankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

@Component("travelJob")
public class TravelJob {

    @Autowired
    private RemoteStrategyRankService remoteStrategyRankService;

    @Autowired
    private RemoteStrategyConditionService remoteStrategyConditionService;

    public void test(){
        System.err.println(new Date().toLocaleString());
    }

    public void rankStatisJob(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String now = sdf.format(date);

//        LocalDateTime localnow = LocalDateTime.now();
//        ZoneId zoneId = ZoneId.systemDefault();
//        Instant instant = localnow.atZone(zoneId).toInstant();
//        Date now = Date.from(instant);

//        System.err.println(now.toLocaleString());
        System.err.println(now);

        remoteStrategyRankService.rankJob(1,now);
        remoteStrategyRankService.rankJob(2,now);
        remoteStrategyRankService.rankJob(3,now);
        System.out.println("rankStatisJob执行完成");
    }

    public void conditionStatisJob(){
        Date now = new Date();
        remoteStrategyConditionService.conditionJob(1,now);
        remoteStrategyConditionService.conditionJob(2,now);
        remoteStrategyConditionService.conditionJob(3,now);
        System.out.println("condition数据统计完成");
    }

}
